package com.qdsg.ysg.doctor.ui;//package com.qdsg.ysg.doctor.ui;
//
//import android.Manifest;
//import android.app.ProgressDialog;
//import android.content.Intent;
//import android.content.pm.PackageManager;
//import android.net.Uri;
//import android.os.Build;
//import android.os.Bundle;
//import android.os.Environment;
//import android.provider.MediaStore;
//import android.support.annotation.NonNull;
//import android.support.v4.app.ActivityCompat;
//import android.support.v4.content.ContextCompat;
//import android.support.v4.content.FileProvider;
//import android.support.v7.widget.GridLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.text.Editable;
//import android.text.TextUtils;
//import android.text.TextWatcher;
//import android.util.Log;
//import android.view.Gravity;
//import android.view.KeyEvent;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.EditText;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.TextView;
//import android.widget.Toast;
//
//import com.rest.business.RestProxy;
//import com.rest.exception.BusinessException;
//import com.rest.response.BaseResponse;
//import com.rest.response.ConsulationDetailResponse;
//import com.rest.response.Patient;
//import com.rest.response.PatientResponse;
//import com.rest.response.PicUploadResponse;
//
//import java.io.File;
//import java.io.IOException;
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//import java.util.Timer;
//import java.util.TimerTask;
//
//import butterknife.BindView;
//import butterknife.OnClick;
//import io.reactivex.Observer;
//import io.reactivex.disposables.Disposable;
//import com.qdsg.ysg.doctor.R;
//import com.qdsg.ysg.doctor.base.BaseActivity;
//import com.qdsg.ysg.doctor.base.BaseApplication;
//import com.qdsg.ysg.doctor.ui.dialog.SelectHospitalDialogForConsultationFragment;
//import com.qdsg.ysg.doctor.ui.dialog.SelectHospitalDialogFragment;
//import com.qdsg.ysg.doctor.ui.widget.CustomPopWindow;
//import com.qdsg.ysg.doctor.util.ImageLoaderHelper;
//import com.qdsg.ysg.doctor.util.MatchUtil;
//import com.qdsg.ysg.doctor.util.UriUtils;
//
///**
// * Created by Administrator on 2018/5/28.
// */
//
//public class AddReferralActivity extends BaseActivity {
//    public static final int REQUEST_OCT_OPEN_CAMERA = 0x011;
//    public static final int REQUEST_OCT_GALLERY = 0x022;
//    public static final int REQUEST_YDCZ_OPEN_CAMERA = 0x033;
//    public static final int REQUEST_YDCZ_GALLERY = 0x044;
//    public static final int REQUEST_ABC_OPEN_CAMERA = 0x055;
//    public static final int REQUEST_ABC_GALLERY = 0x066;
//        public static final int REQUEST_GYFXY_OPEN_CAMERA = 0x077;
//    public static final int REQUEST_GYFXY_GALLERY = 0x088;
////    public static final int REQUEST_JMNPJ_OPEN_CAMERA = 0x111;
////    public static final int REQUEST_JMNPJ_GALLERY = 0x122;
////    public static final int REQUEST_LXD_OPEN_CAMERA = 0x133;
////    public static final int REQUEST_LXD_GALLERY = 0x144;
////    public static final int REQUEST_SYJ_OPEN_CAMERA = 0x155;
////    public static final int REQUEST_SYJ_GALLERY = 0x166;
//    public static final int REQUEST_BL_OPEN_CAMERA = 0x177;
//    public static final int REQUEST_BL_GALLERY = 0x188;
//    //原图像 URI
//    public Uri imgUriOri;
//    //原图像 路径
//    public static String imgPathOri;
//
//    @BindView(R.id.recyclerView_shjy)
//    RecyclerView recyclerView_eye_photo;
//    List<ConsulationDetailResponse.Photo> list_eye_photo = new ArrayList();
//    MyAdapter adapter_eye_photo;
//
//    @BindView(R.id.recyclerView_myjy)
//    RecyclerView recyclerView_oct;
//    List<ConsulationDetailResponse.Photo> list_oct = new ArrayList();
//    MyAdapter adapter_oct;
//
//    @BindView(R.id.recyclerView_lcjc)
//    RecyclerView recyclerView_abc;
//    List<ConsulationDetailResponse.Photo> list_abc = new ArrayList();
//    MyAdapter adapter_abc;
//
//    @BindView(R.id.recyclerView_wswj)
//    RecyclerView recyclerView_bl;
//    List<ConsulationDetailResponse.Photo> list_bl = new ArrayList();
//    MyAdapter adapter_bl;
//
//    @BindView(R.id.recyclerView_jzjy)
//    RecyclerView recyclerView_gyfxy;
//    List<ConsulationDetailResponse.Photo> list_gyfxy = new ArrayList();
//    MyAdapter adapter_gyfxy;
////
////    @BindView(R.id.recyclerView_gyfxy)
////    RecyclerView recyclerView_gyfxy;
////    List<String> list_jmnpj = new ArrayList();
////    MyAdapter adapter_jmnpj;
////
////    @BindView(R.id.recyclerView_lxd)
////    RecyclerView recyclerView_lxd;
////    List<String> list_lxd = new ArrayList();
////    MyAdapter adapter_lxd;
////
////    @BindView(R.id.recyclerView_syj)
////    RecyclerView recyclerView_syj;
////    List<String> list_syj = new ArrayList();
////    MyAdapter adapter_syj;
//
//    @BindView(R.id.btn_select_hospital)
//    TextView btn_select_hospital;
//
//    @BindView(R.id.edt_id_card)
//    EditText edt_id_card;
//
//    @BindView(R.id.edt_name)
//    EditText edt_name;
//
//    @BindView(R.id.edt_gender)
//    TextView edt_gender;
//
//    @BindView(R.id.edt_phone)
//    EditText edt_phone;
//
//    @BindView(R.id.edt_address)
//    EditText edt_address;
//
//    @BindView(R.id.edt_reason)
//    EditText edt_reason;
//
//    @BindView(R.id.edt_naked_left_eye)
//    EditText edt_naked_left_eye;
//
//    @BindView(R.id.edt_naked_right_eye)
//    EditText edt_naked_right_eye;
//
//    @BindView(R.id.edt_cured_left_eye)
//    EditText edt_cured_left_eye;
//
//    @BindView(R.id.edt_cured_right_eye)
//    EditText edt_cured_right_eye;
//
//    @BindView(R.id.edt_pressure_left_eye)
//    EditText edt_pressure_left_eye;
//
//    @BindView(R.id.edt_pressure_right_eye)
//    EditText edt_pressure_right_eye;
//
//    @BindView(R.id.edt_zs)
//    EditText edt_zs;
//
//    @BindView(R.id.edt_xbs)
//    EditText edt_xbs;
//
//    @BindView(R.id.edt_jws)
//    EditText edt_jws;
//
//    @BindView(R.id.edt_gms)
//    EditText edt_gms;
//
//    @BindView(R.id.edt_apply_doctor)
//    EditText edt_apply_doctor;
//
//    @BindView(R.id.edt_apply_hospital)
//    EditText edt_apply_hospital;
//
//    @BindView(R.id.tv_reason)
//    TextView tv_reason;
//
//    @BindView(R.id.tv_title)
//    TextView tv_title;
//
//    @BindView(R.id.select_department)
//    TextView select_department;
//
//    @BindView(R.id.select_doctor)
//    TextView select_doctor;
//
//    @BindView(R.id.btn_select_hospital_1)
//    TextView btn_select_hospital_1;
//
//    @BindView(R.id.select_department_1)
//    TextView select_department_1;
//
//    @BindView(R.id.select_doctor_1)
//    TextView select_doctor_1;
//
//    @BindView(R.id.second_doctor_container)
//    LinearLayout second_doctor_container;
//
//    @BindView(R.id.first_doctor_container)
//    LinearLayout first_doctor_container;
//
//    @BindView(R.id.apply_container)
//    LinearLayout apply_container;
//
//    @BindView(R.id.btn_add_second_doctor)
//    TextView btn_add_second_doctor;
//
//    @BindView(R.id.btn_start_consultation)
//    TextView btn_start_consultation;
//    @BindView(R.id.btn_save)
//    TextView btn_save;
//
//    public int type;
//    public ProgressDialog dialog;
//    public Patient diagnoseId;
//    public Patient patient;
//
//    private long hospital_id, department_id, doctor_id, time_id;
//    private long hospital_id_1, department_id_1, doctor_id_1;
//    private String schedule_id, hospital_name, startTime = "";
//
//    private SelectHospitalDialogFragment mSelectHospitalDialogFragment;
//    private SelectHospitalDialogForConsultationFragment mSelectHospitalDialogForConsultationFragment;
//    private CustomPopWindow mListPopWindow;
//
//    private String octURL = "", ydczURL = "", abcURL = "", gyfxyURL = "", jmnpjURL = "", lxdURL = "", syjURL = "", blURL = "";
//
//    @Override
//    protected void initViews() {
//        GridLayoutManager manager_eye_photo = new GridLayoutManager(this, 5);
//        recyclerView_eye_photo.setLayoutManager(manager_eye_photo);
//        adapter_eye_photo = new MyAdapter(list_eye_photo, REQUEST_YDCZ_OPEN_CAMERA, REQUEST_YDCZ_GALLERY);
//        recyclerView_eye_photo.setAdapter(adapter_eye_photo);
//
//        GridLayoutManager manager_oct = new GridLayoutManager(this, 5);
//        recyclerView_oct.setLayoutManager(manager_oct);
//        adapter_oct = new MyAdapter(list_oct, REQUEST_OCT_OPEN_CAMERA, REQUEST_OCT_GALLERY);
//        recyclerView_oct.setAdapter(adapter_oct);
//
//        GridLayoutManager manager_abc = new GridLayoutManager(this, 5);
//        recyclerView_abc.setLayoutManager(manager_abc);
//        adapter_abc = new MyAdapter(list_abc, REQUEST_ABC_OPEN_CAMERA, REQUEST_ABC_GALLERY);
//        recyclerView_abc.setAdapter(adapter_abc);
//
//        GridLayoutManager manager_bl = new GridLayoutManager(this, 5);
//        recyclerView_bl.setLayoutManager(manager_bl);
//        adapter_bl = new MyAdapter(list_bl, REQUEST_BL_OPEN_CAMERA, REQUEST_BL_GALLERY);
//        recyclerView_bl.setAdapter(adapter_bl);
//
//        GridLayoutManager manager_gyfxy = new GridLayoutManager(this, 5);
//        recyclerView_gyfxy.setLayoutManager(manager_gyfxy);
//        adapter_gyfxy = new MyAdapter(list_gyfxy, REQUEST_GYFXY_OPEN_CAMERA, REQUEST_GYFXY_GALLERY);
//        recyclerView_gyfxy.setAdapter(adapter_gyfxy);
//
////
////        GridLayoutManager manager_jmnpj = new GridLayoutManager(this, 5);
////        recyclerView_jmnpj.setLayoutManager(manager_jmnpj);
////        adapter_jmnpj = new MyAdapter(list_jmnpj, REQUEST_JMNPJ_OPEN_CAMERA, REQUEST_JMNPJ_GALLERY);
////        recyclerView_jmnpj.setAdapter(adapter_jmnpj);
////
////        GridLayoutManager manager_lxd = new GridLayoutManager(this, 5);
////        recyclerView_lxd.setLayoutManager(manager_lxd);
////        adapter_lxd = new MyAdapter(list_lxd, REQUEST_LXD_OPEN_CAMERA, REQUEST_LXD_GALLERY);
////        recyclerView_lxd.setAdapter(adapter_lxd);
////
////        GridLayoutManager manager_syj = new GridLayoutManager(this, 5);
////        recyclerView_syj.setLayoutManager(manager_syj);
////        adapter_syj = new MyAdapter(list_syj, REQUEST_SYJ_OPEN_CAMERA, REQUEST_SYJ_GALLERY);
////        recyclerView_syj.setAdapter(adapter_syj);
//
//
//        edt_id_card.setOnEditorActionListener(new TextView.OnEditorActionListener() {
//            @Override
//            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
//                if (MatchUtil.checkIDCard(edt_id_card.getText().toString().trim(), AddReferralActivity.this)) {
//                    getPatientByIDCard();
//                }
//                return false;
//            }
//        });
//        edt_id_card.addTextChangedListener(new TextWatcher() {
//            @Override
//            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//
//            }
//
//            @Override
//            public void onTextChanged(CharSequence s, int start, int before, int count) {
//
//            }
//
//            @Override
//            public void afterTextChanged(Editable s) {
//                if (edt_id_card.getText().toString().trim().length() == 18) {
//                    if (MatchUtil.checkIDCard(edt_id_card.getText().toString().trim(), AddReferralActivity.this)) {
//                        getPatientByIDCard();
//                    }
//                }
//            }
//        });
//
//        if (type == 0) {
//            tv_reason.setText("转诊理由");
//            tv_title.setText("新建转诊");
//        } else if (type == 2) {
//            tv_reason.setText("初步诊断：");
//            tv_title.setText("新建病理会诊");
//            btn_start_consultation.setVisibility(View.VISIBLE);
//        } else if (type == 1) {
//            tv_reason.setText("初步诊断：");
//            tv_title.setText("新建视频会诊");
//            btn_add_second_doctor.setVisibility(View.VISIBLE);
//        } else if (type == 3) {
//            tv_reason.setText("初步诊断：");
//            tv_title.setText("编辑视频会诊");
//            first_doctor_container.setVisibility(View.GONE);
//            btn_add_second_doctor.setVisibility(View.GONE);
//            apply_container.setVisibility(View.VISIBLE);
//            getDetail();
//        } else if (type == 4) {
//            tv_reason.setText("初步诊断：");
//            tv_title.setText("编辑病理会诊");
//            btn_add_second_doctor.setVisibility(View.GONE);
//            apply_container.setVisibility(View.VISIBLE);
//            btn_start_consultation.setVisibility(View.GONE);
//            btn_save.setVisibility(View.VISIBLE);
//            getDetail();
//        }
//    }
//
//    @Override
//    protected void initData() {
//        type = getIntent().getIntExtra("type", -1);
//        diagnoseId = (Patient) getIntent().getSerializableExtra("diagnoseId");
//    }
//
//    @Override
//    protected int getLayoutResource() {
//        return R.layout.activity_add_referral;
//    }
//
//
//    class MyAdapter extends RecyclerView.Adapter<MyAdapter.Holder> {
//        List<ConsulationDetailResponse.Photo> list;
//        int type_open_camera;
//        int type_gallery;
//
//        public MyAdapter(List<ConsulationDetailResponse.Photo> list, int type_open_camera, int type_gallery) {
//            this.list = list;
//            this.type_open_camera = type_open_camera;
//            this.type_gallery = type_gallery;
//        }
//
//        @Override
//        public MyAdapter.Holder onCreateViewHolder(ViewGroup parent, int viewType) {
//            MyAdapter.Holder myHolder = new MyAdapter.Holder(LayoutInflater.from(AddReferralActivity.this).inflate(R.layout.item_photo, parent, false));
//            return myHolder;
//        }
//
//        @Override
//        public void onBindViewHolder(final MyAdapter.Holder holder, final int position) {
//            if (position - list.size() == 0) {
//                holder.image.setImageResource(R.mipmap.btn_add_photo);
////                holder.itemView.setOnClickListener(new View.OnClickListener() {
////                    @Override
////                    public void onClick(View v) {
////                        if (position - list.size() == 0) {
////                            openGallery(type_gallery);
////                        } else {
////                            openCamera(type_open_camera);
////                        }
////                    }
////                });
//                holder.btn_del_photo.setVisibility(View.GONE);
//            } else if (position - list.size() == 1) {
//                holder.image.setImageResource(R.mipmap.btn_take_photo);
////                holder.image.setOnClickListener(new View.OnClickListener() {
////                    @Override
////                    public void onClick(View v) {
////                        if (position - list.size() == 0) {
////                            openGallery(type_gallery);
////                        } else {
////                            openCamera(type_open_camera);
////                        }
////                    }
////                });
//                holder.btn_del_photo.setVisibility(View.GONE);
//            } else {
//                if (!TextUtils.isEmpty(list.get(position).url)) {
//                    ImageLoaderHelper.getInstance().GlideImageLoaderByStream(AddReferralActivity.this, list.get(position).url + ".sm", holder.image);
////                    holder.image.setOnClickListener(new View.OnClickListener() {
////                        @Override
////                        public void onClick(View v) {
////                            Bundle bundle = new Bundle();
////                            bundle.putString("url", list.get(position).url);
////                            AddReferralActivity.this.startActivity(BigImageActivity.class, bundle);
////                        }
////                    });
//                } else if (!TextUtils.isEmpty(list.get(position).uri)) {
//                    ImageLoaderHelper.getInstance().GlideImageLoader(AddReferralActivity.this, list.get(position).uri, holder.image);
////                    holder.image.setOnClickListener(new View.OnClickListener() {
////                        @Override
////                        public void onClick(View v) {
////                            Bundle bundle = new Bundle();
////                            bundle.putString("url", list.get(position).uri);
////                            AddReferralActivity.this.startActivity(BigImageActivity.class, bundle);
////                        }
////                    });
//                }
//                holder.btn_del_photo.setVisibility(View.VISIBLE);
//                holder.btn_del_photo.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        list.remove(position);
//                        ;
//                        notifyDataSetChanged();
//                    }
//                });
//
//            }
//            holder.image.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    if (position - list.size() == 0) {
//                        openGallery(type_gallery);
//                    } else if (position - list.size() == 1) {
//                        openCamera(type_open_camera);
//                    } else if (!TextUtils.isEmpty(list.get(position).uri)) {
//                        Bundle bundle = new Bundle();
//                        bundle.putString("url", list.get(position).uri);
//                        bundle.putInt("type", 1);
//                        AddReferralActivity.this.startActivity(BigImageActivity.class, bundle);
//                    } else if (!TextUtils.isEmpty(list.get(position).url)) {
//                        Bundle bundle = new Bundle();
//                        bundle.putString("url", list.get(position).url);
//                        bundle.putInt("type", 2);
//                        AddReferralActivity.this.startActivity(BigImageActivity.class, bundle);
//                    }
//                }
//            });
//
//
//        }
//
//        @Override
//        public int getItemCount() {
//            return list.size() + 2;
//        }
//
//
//        class Holder extends RecyclerView.ViewHolder {
//
//            ImageView image;
//            ImageView btn_del_photo;
//
//            public Holder(View itemView) {
//                super(itemView);
//                image = itemView.findViewById(R.id.image);
//                btn_del_photo = itemView.findViewById(R.id.btn_del_photo);
//            }
//        }
//    }
//
//    @OnClick(R.id.btn_select_hospital)
//    void btn_select_hospital() {
//        if (type == 0) {
//            showDialog();
//        } else {
//            showDialogForConsultation(0);
//        }
//    }
//
//    @OnClick(R.id.btn_add_second_doctor)
//    void btn_add_second_doctor() {
//        btn_add_second_doctor.setVisibility(View.GONE);
//        second_doctor_container.setVisibility(View.VISIBLE);
//    }
//
//    @OnClick(R.id.btn_select_hospital_1)
//    void btn_select_hospital_1() {
//        if (type == 0) {
//            showDialog();
//        } else {
//            showDialogForConsultation(1);
//        }
//    }
//
//
//    private void showDialog() {
//        if (mSelectHospitalDialogFragment == null) {
//            mSelectHospitalDialogFragment = mSelectHospitalDialogFragment.newInstance();
//            mSelectHospitalDialogFragment.show(getSupportFragmentManager(), "mSelectHospitalDialogFragment");
//            mSelectHospitalDialogFragment.setmListener(new SelectHospitalDialogFragment.OnItemClickListener() {
//
//                @Override
//                public void onConfirm(String text, long hospital_id, long department_id, long doctor_id, String schedule_id, long time_id, String startTime) {
//                    btn_select_hospital.setText(text);
//                    AddReferralActivity.this.hospital_id = hospital_id;
//                    AddReferralActivity.this.department_id = department_id;
//                    AddReferralActivity.this.doctor_id = doctor_id;
//                    AddReferralActivity.this.schedule_id = schedule_id;
//                    AddReferralActivity.this.time_id = time_id;
//                    AddReferralActivity.this.startTime = startTime;
//
//                    mSelectHospitalDialogFragment.dismiss();
//
//                }
//            });
//        } else if (!mSelectHospitalDialogFragment.isAdded() && !mSelectHospitalDialogFragment.isShowing()) {
//            mSelectHospitalDialogFragment.show(getSupportFragmentManager(), "mSelectHospitalDialogFragment");
//        }
//    }
//
//    private void showDialogForConsultation(final int doctorCount) {
////        if (mSelectHospitalDialogForConsultationFragment == null) {
//        mSelectHospitalDialogForConsultationFragment = mSelectHospitalDialogForConsultationFragment.newInstance();
//        mSelectHospitalDialogForConsultationFragment.show(getSupportFragmentManager(), "mSelectHospitalDialogForConsultationFragment");
//        mSelectHospitalDialogForConsultationFragment.setmListener(new SelectHospitalDialogForConsultationFragment.OnItemClickListener() {
//
//            @Override
//            public void onConfirm(String text, String text1, String text2, long long1, long long2, long long3) {
//                if (doctorCount == 0) {
//                    hospital_id = long1;
//                    department_id = long2;
//                    doctor_id = long3;
//                    btn_select_hospital.setText(text);
//                    select_department.setText(text1);
//                    select_doctor.setText(text2);
//                } else if (doctorCount == 1) {
//                    btn_select_hospital_1.setText(text);
//                    select_department_1.setText(text1);
//                    select_doctor_1.setText(text2);
//                    hospital_id_1 = long1;
//                    department_id_1 = long2;
//                    doctor_id_1 = long3;
//                    if (doctor_id == doctor_id_1) {
//                        Toast.makeText(AddReferralActivity.this, "请选择不同医生", Toast.LENGTH_SHORT).show();
//                        btn_select_hospital_1.setText("");
//                        select_department_1.setText("");
//                        select_doctor_1.setText("");
//                        hospital_id_1 = 0;
//                        department_id_1 = 0;
//                        doctor_id_1 = 0;
//                    }
//                }
//                mSelectHospitalDialogForConsultationFragment.dismiss();
//                mSelectHospitalDialogForConsultationFragment = null;
//
//            }
//        });
//    }
////        else if (!mSelectHospitalDialogForConsultationFragment.isAdded() && !mSelectHospitalDialogForConsultationFragment.isShowing()) {
////            mSelectHospitalDialogForConsultationFragment.show(getSupportFragmentManager(), "mSelectHospitalDialogForConsultationFragment");
////        }
////    }
//
//
//    private void getPatientByIDCard() {
//        RestProxy.getInstance().getPatientByIDCard(edt_id_card.getText().toString(), new Observer<PatientResponse>() {
//            @Override
//            public void onSubscribe(Disposable d) {
//
//            }
//
//            @Override
//            public void onNext(PatientResponse patientResponse) {
//                if (patientResponse.data.patient != null) {
//                    edt_name.setText(patientResponse.data.patient.patientName);
//                    edt_gender.setText(patientResponse.data.patient.patientSex);
//                    edt_address.setText(patientResponse.data.patient.patientAddr);
////                    edt_reason.setText(patientResponse.data.patient.preDiagnose);
////                edt_naked_left_eye.setText(patientResponse.data.patient.nakedEyesightLeft);
////                edt_naked_right_eye.setText(patientResponse.data.patient.nakedEyesightRight);
////                edt_cured_left_eye.setText(patientResponse.data.patient.curedEyesightLeft);
////                edt_cured_right_eye.setText(patientResponse.data.patient.curedEyesightRight);
////                edt_pressure_left_eye.setText(patientResponse.data.patient.eyePressureLeft);
////                edt_pressure_right_eye.setText(patientResponse.data.patient.eyePressureRight);
//                    edt_phone.setText(patientResponse.data.patient.patientPhone);
////                edt_zs.setText(patientResponse.data.patient.medhisZs);
////                edt_xbs.setText(patientResponse.data.patient.medhisXbs);
////                edt_jws.setText(patientResponse.data.patient.medhisJws);
////                edt_gms.setText(patientResponse.data.patient.medhisGms);
//
////                list_eye_photo.clear();
////                list_eye_photo.addAll(patientResponse.data.YDCZ);
////                adapter_eye_photo.notifyDataSetChanged();
////
////                ydczURL = "";
////                for (String s : list_eye_photo) {
////                    ydczURL =ydczURL + s+",";
////                }
////
////                abcURL = "";
////                for (String s : list_abc) {
////                    abcURL =abcURL + s+",";
////                }
////
////                gyfxyURL = "";
////                for (String s : list_gyfxy) {
////                    gyfxyURL =gyfxyURL + s+",";
////                }
////
////                lxdURL = "";
////                for (String s : list_lxd) {
////                    lxdURL =lxdURL + s+",";
////                }
////
////                jmnpjURL = "";
////                for (String s : list_jmnpj) {
////                    jmnpjURL =jmnpjURL + s+",";
////                }
////
////                octURL = "";
////                for (String s : list_oct) {
////                    octURL =octURL + s+",";
////                }
////
////                syjURL = "";
////                for (String s : list_syj) {
////                    syjURL =syjURL + s+",";
////                }
////
////                list_oct.clear();
////                list_oct.addAll(patientResponse.data.OCT);
////                adapter_oct.notifyDataSetChanged();
////
////                list_abc.clear();
////                list_abc.addAll(patientResponse.data.ABC);
////                adapter_abc.notifyDataSetChanged();
////
////                list_gyfxy.clear();
////                list_gyfxy.addAll(patientResponse.data.GYFXY);
////                adapter_gyfxy.notifyDataSetChanged();
////
////                list_jmnpj.clear();
////                list_jmnpj.addAll(patientResponse.data.JMNPJ);
////                adapter_jmnpj.notifyDataSetChanged();
////
////                list_lxd.clear();
////                list_lxd.addAll(patientResponse.data.LXD);
////                adapter_lxd.notifyDataSetChanged();
////
////                list_syj.clear();
////                list_syj.addAll(patientResponse.data.SYJ);
////                adapter_syj.notifyDataSetChanged();
//                }
//            }
//
//            @Override
//            public void onError(Throwable e) {
//                if (e instanceof BusinessException) {
//                    if (((BusinessException) e).errorCode == 700) {
//                        Toast.makeText(AddReferralActivity.this, "登录失败，请重新登录", Toast.LENGTH_SHORT).show();
//                    }
//                }
//            }
//
//            @Override
//            public void onComplete() {
//
//            }
//        });
//    }
//
//
//    protected void openGallery(int requestCode) {
//
//        if (ContextCompat.checkSelfPermission(this,
//                Manifest.permission.WRITE_EXTERNAL_STORAGE)
//                != PackageManager.PERMISSION_GRANTED) {
//            ActivityCompat.requestPermissions(this,
//                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
//                    10);
//
//        } else {
//            choosePhoto(requestCode);
//        }
//
//
//    }
//
//
//    private void openCamera(int requestCode) {
//        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);// 打开相机
//        File oriPhotoFile = null;
//        try {
//            oriPhotoFile = createOriImageFile();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        if (oriPhotoFile != null) {
//            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
//                imgUriOri = Uri.fromFile(oriPhotoFile);
//            } else {
//                imgUriOri = FileProvider.getUriForFile(this, "com.qdsg.ysg.doctor.provider", oriPhotoFile);
//            }
//            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
//            intent.putExtra(MediaStore.EXTRA_OUTPUT, imgUriOri);
//            startActivityForResult(intent, requestCode);
//
////            Log.i(TAG, "openCamera_imgPathOri:" + imgPathOri);
////            Log.i(TAG, "openCamera_imgUriOri:" + imgUriOri.toString());
//        }
//    }
//
//    private void choosePhoto(int requestCode) {
//        Intent intent = new Intent();
//        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
//            intent.setAction(Intent.ACTION_PICK);
////            intent.setType("image/*");//相片类型
//        } else {
//            intent.setAction(Intent.ACTION_GET_CONTENT);
////            intent.setAction(Intent.ACTION_PICK);
//        }
//        intent.setType("image/*");
//        startActivityForResult(intent, requestCode);
//    }
//
//
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        super.onActivityResult(requestCode, resultCode, data);
//        if (resultCode != RESULT_OK) {
//            return;
//        }
//        ConsulationDetailResponse response = new ConsulationDetailResponse();
//        ConsulationDetailResponse.Photo photo = response.new Photo();
//        //data的返回值根据
//        switch (requestCode) {
//            case REQUEST_OCT_OPEN_CAMERA:
//                photo.uri = imgPathOri;
////                list_oct.add(photo);
////                adapter_oct.notifyDataSetChanged();
//                uploadFile("SHJY", imgPathOri, list_oct, photo, adapter_oct);
//                break;
//            case REQUEST_OCT_GALLERY:
//                if (data != null) {
//                    Uri imgUriSel = data.getData();
//                    String imgPathSel = UriUtils.formatUri(this, imgUriSel);
//                    photo.uri = imgPathSel;
////                    list_oct.add(photo);
////                    adapter_oct.notifyDataSetChanged();
//                    uploadFile("SHJY", imgPathSel, list_oct, photo, adapter_oct);
//                }
//                break;
//            case REQUEST_YDCZ_OPEN_CAMERA:
//                photo.uri = imgPathOri;
////                list_eye_photo.add(photo);
////                adapter_eye_photo.notifyDataSetChanged();
//                uploadFile("MYJY", imgPathOri, list_eye_photo, photo, adapter_eye_photo);
//                break;
//            case REQUEST_YDCZ_GALLERY:
//                if (data != null) {
//                    Uri imgUriSel = data.getData();
//                    String imgPathSel = UriUtils.formatUri(this, imgUriSel);
//                    photo.uri = imgPathSel;
////                    list_eye_photo.add(photo);
////                    adapter_eye_photo.notifyDataSetChanged();
//                    uploadFile("MYJY", imgPathSel, list_eye_photo, photo, adapter_eye_photo);
//                }
//                break;
//            case REQUEST_ABC_OPEN_CAMERA:
//                photo.uri = imgPathOri;
////                list_abc.add(photo);
////                adapter_abc.notifyDataSetChanged();
//                uploadFile("LCJC", imgPathOri, list_abc, photo, adapter_abc);
//                break;
//            case REQUEST_ABC_GALLERY:
//                if (data != null) {
//                    Uri imgUriSel = data.getData();
//                    String imgPathSel = UriUtils.formatUri(this, imgUriSel);
//                    photo.uri = imgPathSel;
////                    list_abc.add(photo);
////                    adapter_abc.notifyDataSetChanged();
//                    uploadFile("LCJC", imgPathSel, list_abc, photo, adapter_abc);
//                }
//                break;
//            case REQUEST_BL_OPEN_CAMERA:
//                photo.uri = imgPathOri;
////                list_bl.add(photo);
////                adapter_bl.notifyDataSetChanged();
//                uploadFile("WSWJ", imgPathOri, list_bl, photo, adapter_bl);
//                break;
//            case REQUEST_BL_GALLERY:
//                if (data != null) {
//                    Uri imgUriSel = data.getData();
//                    String imgPathSel = UriUtils.formatUri(this, imgUriSel);
//                    photo.uri = imgPathSel;
////                    list_bl.add(photo);
////                    adapter_bl.notifyDataSetChanged();
//                    uploadFile("WSWJ", imgPathSel, list_bl, photo, adapter_bl);
//                }
//                break;
//            case REQUEST_GYFXY_OPEN_CAMERA:
//                photo.uri = imgPathOri;
////                list_bl.add(photo);
////                adapter_bl.notifyDataSetChanged();
//                uploadFile("JZJY", imgPathOri, list_bl, photo, adapter_bl);
//                break;
//            case REQUEST_GYFXY_GALLERY:
//                if (data != null) {
//                    Uri imgUriSel = data.getData();
//                    String imgPathSel = UriUtils.formatUri(this, imgUriSel);
//                    photo.uri = imgPathSel;
////                    list_bl.add(photo);
////                    adapter_bl.notifyDataSetChanged();
//                    uploadFile("JZJY", imgPathSel, list_bl, photo, adapter_bl);
//                }
//                break;
////            case REQUEST_JMNPJ_OPEN_CAMERA:
////                list_jmnpj.add(imgPathOri);
////                adapter_jmnpj.notifyDataSetChanged();
////                uploadFile("JMNPJ", imgPathOri);
////                break;
////            case REQUEST_JMNPJ_GALLERY:
////                if (data != null) {
////                    Uri imgUriSel = data.getData();
////                    String imgPathSel = UriUtils.formatUri(this, imgUriSel);
////                    list_jmnpj.add(imgPathSel);
////                    adapter_jmnpj.notifyDataSetChanged();
////                    uploadFile("JMNPJ", imgPathSel);
////                }
////                break;
////            case REQUEST_LXD_OPEN_CAMERA:
////                list_lxd.add(imgPathOri);
////                adapter_lxd.notifyDataSetChanged();
////                uploadFile("LXD", imgPathOri);
////                break;
////            case REQUEST_LXD_GALLERY:
////                if (data != null) {
////                    Uri imgUriSel = data.getData();
////                    String imgPathSel = UriUtils.formatUri(this, imgUriSel);
////                    list_lxd.add(imgPathSel);
////                    adapter_lxd.notifyDataSetChanged();
////                    uploadFile("LXD", imgPathSel);
////                }
////                break;
////            case REQUEST_SYJ_OPEN_CAMERA:
////                list_syj.add(imgPathOri);
////                adapter_syj.notifyDataSetChanged();
////                uploadFile("SYJ", imgPathOri);
////                break;
////            case REQUEST_SYJ_GALLERY:
////                if (data != null) {
////                    Uri imgUriSel = data.getData();
////                    String imgPathSel = UriUtils.formatUri(this, imgUriSel);
////                    list_syj.add(imgPathSel);
////                    adapter_syj.notifyDataSetChanged();
////                    uploadFile("SYJ", imgPathSel);
////                }
////                break;
//        }
//    }
//
//    @Override
//    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
//        if (requestCode == 10) {
//            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
////                choosePhoto();
//            } else {
//                // Permission Denied
//                Toast.makeText(this, "Permission Denied", Toast.LENGTH_SHORT).show();
//            }
//        }
//
//        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
//    }
//
//
//    /**
//     * 创建原图像保存的文件
//     *
//     * @return
//     * @throws IOException
//     */
//    protected File createOriImageFile() throws IOException {
//        String imgNameOri = "HomePic_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
//        File pictureDirOri = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath() + "/OriPicture");
//        if (!pictureDirOri.exists()) {
//            pictureDirOri.mkdirs();
//        }
//        File image = File.createTempFile(
//                imgNameOri,         /* prefix */
//                ".jpg",             /* suffix */
//                pictureDirOri       /* directory */
//        );
//        imgPathOri = image.getAbsolutePath();
//        return image;
//    }
//
//    private void uploadFile(final String picType, String imgPathSel, final List<ConsulationDetailResponse.Photo> list, final ConsulationDetailResponse.Photo photo, final MyAdapter myAdapter) {
//        RestProxy.getInstance().uploadFile(picType, new File(imgPathSel), new Observer<PicUploadResponse>() {
//            @Override
//            public void onSubscribe(Disposable d) {
//                dialog = ProgressDialog.show(AddReferralActivity.this, "提示", "正在上传中…", true, false, null);
//            }
//
//            @Override
//            public void onNext(PicUploadResponse picUploadResponse) {
//                photo.resourceId = picUploadResponse.data.resourceId;
//                list.add(photo);
//                myAdapter.notifyDataSetChanged();
////                if (picType == "OCT") {
////                    octURL = octURL + picUploadResponse.data.resourceId + ",";
////                }
////                if (picType == "YDCZ") {
////                    ydczURL = ydczURL + picUploadResponse.data.resourceId + ",";
////                }
////                if (picType == "ABC") {
////                    abcURL = abcURL + picUploadResponse.data.resourceId + ",";
////                }
////                if (picType == "BL") {
////                    blURL = blURL + picUploadResponse.data.resourceId + ",";
////                }
//            }
//
//            @Override
//            public void onError(Throwable e) {
//                dialog.dismiss();
//            }
//
//            @Override
//            public void onComplete() {
//                dialog.dismiss();
//            }
//        });
//    }
//
//    @OnClick(R.id.btn_save)
//    void btn_save() {
//        if (type == 0) {
////            addReferral();
//        } else if (type == 1) {
//            addConsultation();
//        } else if (type == 2) {
//            saveConsultation();
//        } else if (type == 3) {
//            editConsultation();
//        } else if (type == 4) {
//            editConsultation();
//        }
//    }
//
//    @OnClick(R.id.btn_start_consultation)
//    void btn_start_consultation() {
//        if (type == 2) {
//            startConsultation("", "", "");
//        } else if (type == 4) {
//            startConsultation(patient.patientId, patient.diagnoseId, patient.medhisId);
//        }
//    }
//
//
////    private void addReferral() {
////        if (hospital_id == 0 || department_id == 0 || doctor_id == 0) {
////            Toast.makeText(this, "请选择医院", Toast.LENGTH_SHORT).show();
////            return;
////        }
////        RestProxy.getInstance().addReferral(time_id + "", hospital_id + "", edt_name.getText().toString().trim(), edt_phone.getText().toString().trim(), edt_id_card.getText().toString().trim(), edt_gender.getText().toString().trim(), edt_address.getText().toString().trim(), startTime, doctor_id + "," + doctor_id_1, edt_reason.getText().toString().trim(), department_id + "", edt_naked_right_eye.getText().toString().trim(), edt_naked_left_eye.getText().toString().trim(), edt_cured_right_eye.getText().toString().trim(), edt_cured_left_eye.getText().toString().trim(), edt_pressure_right_eye.getText().toString().trim(), edt_pressure_left_eye.getText().toString().trim(), edt_zs.getText().toString().trim(), edt_xbs.getText().toString().trim(), edt_jws.getText().toString().trim(), edt_gms.getText().toString().trim(),
////                ydczURL, octURL, abcURL, gyfxyURL, jmnpjURL, lxdURL, syjURL,
////                new Observer<BaseResponse>() {
////                    @Override
////                    public void onSubscribe(Disposable d) {
////
////                    }
////
////                    @Override
////                    public void onNext(BaseResponse baseResponse) {
////                        finish();
////                    }
////
////                    @Override
////                    public void onError(Throwable e) {
////                        if (e instanceof BusinessException) {
////                            Toast.makeText(AddReferralActivity.this, ((BusinessException) e).errorDescription, Toast.LENGTH_SHORT).show();
////                        }
////                    }
////
////                    @Override
////                    public void onComplete() {
////
////                    }
////                });
////    }
//
//
//    private void addConsultation() {
////        if (hospital_id == 0 || department_id == 0 || doctor_id == 0) {
////            Toast.makeText(this, "请选择医院", Toast.LENGTH_SHORT).show();
////            return;
////        }
//        if (!MatchUtil.checkIDCard(edt_id_card.getText().toString().trim(), AddReferralActivity.this)) {
//            Toast.makeText(this, "身份证有误", Toast.LENGTH_SHORT).show();
//            return;
//        }
//
//        ydczURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_eye_photo) {
//
//            ydczURL = ydczURL + photo.resourceId + ",";
//        }
//
//        octURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_oct) {
//
//            octURL = octURL + photo.resourceId + ",";
//        }
//
//        abcURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_abc) {
//
//            abcURL = abcURL + photo.resourceId + ",";
//        }
//
//        blURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_bl) {
//
//            blURL = blURL + photo.resourceId + ",";
//        }
//
//        RestProxy.getInstance().addConsultation(time_id + "", hospital_id + "," + hospital_id_1, edt_name.getText().toString().trim(), edt_phone.getText().toString().trim(), edt_id_card.getText().toString().trim(), edt_gender.getText().toString().trim(), edt_address.getText().toString().trim(), startTime, doctor_id + "," + doctor_id_1, edt_reason.getText().toString().trim(), department_id + "," + department_id_1, edt_naked_right_eye.getText().toString().trim(), edt_naked_left_eye.getText().toString().trim(), edt_cured_right_eye.getText().toString().trim(), edt_cured_left_eye.getText().toString().trim(), edt_pressure_right_eye.getText().toString().trim(), edt_pressure_left_eye.getText().toString().trim(), edt_zs.getText().toString().trim(), edt_xbs.getText().toString().trim(), edt_jws.getText().toString().trim(), edt_gms.getText().toString().trim(),
//                ydczURL, octURL, abcURL, blURL,gyfxyURL, getBirth(), type + "", new Observer<BaseResponse>() {
//                    @Override
//                    public void onSubscribe(Disposable d) {
//
//                    }
//
//                    @Override
//                    public void onNext(BaseResponse baseResponse) {
//                        finish();
//                    }
//
//                    @Override
//                    public void onError(Throwable e) {
//                        if (e instanceof BusinessException) {
//                            if (((BusinessException) e).errorCode == 700) {
//                                Toast.makeText(AddReferralActivity.this, "登录失败，请重新登录", Toast.LENGTH_SHORT).show();
//                            }
//                        }
//                    }
//
//                    @Override
//                    public void onComplete() {
//
//                    }
//                });
//    }
//
//
//    private String getBirth() {
//        String date = "";
//        if (TextUtils.isEmpty(edt_id_card.getText().toString().trim()) || edt_id_card.getText().length() < 18) {
//            return "";
//        }
//        try {
//            String birth = edt_id_card.getText().toString().trim().substring(6, 14);
//            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
//            SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
//            date = sdf1.format(sdf.parse(birth));
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//        return date;
//    }
//
//
//    private void getDetail() {
//        RestProxy.getInstance().getConsultationDetail(diagnoseId.diagnoseId, new Observer<ConsulationDetailResponse>() {
//            @Override
//            public void onSubscribe(Disposable d) {
//
//            }
//
//            @Override
//            public void onNext(ConsulationDetailResponse consulationDetailResponse) {
//                patient = consulationDetailResponse.data.ConsultationMap;
//                edt_name.setText(consulationDetailResponse.data.ConsultationMap.patientName);
//                edt_gender.setText(consulationDetailResponse.data.ConsultationMap.patientSex);
//                edt_id_card.setText(consulationDetailResponse.data.ConsultationMap.patientIdcard);
////                edt_time.setText(consulationDetailResponse.data.ConsultationMap.createDate);
//                edt_phone.setText(consulationDetailResponse.data.ConsultationMap.patientPhone);
////                if (!TextUtils.isEmpty(patient.referralCont)) {
////                    tv_reason.setText(patient.referralCont);
////                }
////                if (!TextUtils.isEmpty(consulationDetailResponse.data.ConsultationMap.preDiagnose)) {
//                System.out.println(consulationDetailResponse.data.ConsultationMap.preDiagnose +"  aaaaaaaaaaaaaaaaaaaa");
//                    edt_reason.setText(consulationDetailResponse.data.ConsultationMap.preDiagnose);
////                }
//                edt_naked_left_eye.setText(consulationDetailResponse.data.ConsultationMap.nakedEyesightLeft);
//                edt_naked_right_eye.setText(consulationDetailResponse.data.ConsultationMap.nakedEyesightRight);
//                edt_cured_left_eye.setText(consulationDetailResponse.data.ConsultationMap.curedEyesightLeft);
//                edt_cured_right_eye.setText(consulationDetailResponse.data.ConsultationMap.curedEyesightRight);
//                edt_pressure_left_eye.setText(consulationDetailResponse.data.ConsultationMap.eyePressureLeft);
//                edt_pressure_right_eye.setText(consulationDetailResponse.data.ConsultationMap.eyePressureRight);
//                edt_zs.setText(consulationDetailResponse.data.ConsultationMap.medhisZs);
//                edt_xbs.setText(consulationDetailResponse.data.ConsultationMap.medhisXbs);
//                edt_jws.setText(consulationDetailResponse.data.ConsultationMap.medhisJws);
//                edt_gms.setText(consulationDetailResponse.data.ConsultationMap.medhisGms);
//                edt_apply_doctor.setText(diagnoseId.initiatorDocName);
//                edt_apply_hospital.setText(diagnoseId.initiatorHosName);
//                if (!TextUtils.isEmpty(consulationDetailResponse.data.docObject.hosId))
//                    hospital_id = Long.valueOf(consulationDetailResponse.data.docObject.hosId);
//                if (!TextUtils.isEmpty(consulationDetailResponse.data.docObject.deptId))
//                    department_id = Long.valueOf(consulationDetailResponse.data.docObject.deptId);
//                if (!TextUtils.isEmpty(consulationDetailResponse.data.docObject.docId))
//                    doctor_id = Long.valueOf(consulationDetailResponse.data.docObject.docId);
//                btn_select_hospital.setText(consulationDetailResponse.data.docObject.hosName);
//                select_department.setText(consulationDetailResponse.data.docObject.deptName);
//                select_doctor.setText(consulationDetailResponse.data.docObject.name);
//
//
////                if (consulationDetailResponse.data.feedbackList.size() > 0) {
////                    tv_feedback.setText(consulationDetailResponse.data.feedbackList.get(0).diagnoseResult);
////                }
//
//                GridLayoutManager manager_eye_photo = new GridLayoutManager(AddReferralActivity.this, 5);
//                recyclerView_eye_photo.setLayoutManager(manager_eye_photo);
////                adapter_eye_photo = new MyAdapter(list_eye_photo);
//                recyclerView_eye_photo.setAdapter(adapter_eye_photo);
//                list_eye_photo.clear();
//                if (consulationDetailResponse.data.SHJY != null)
//                    list_eye_photo.addAll(consulationDetailResponse.data.SHJY);
//                adapter_eye_photo.notifyDataSetChanged();
//
//                GridLayoutManager manager_oct = new GridLayoutManager(AddReferralActivity.this, 5);
//                recyclerView_oct.setLayoutManager(manager_oct);
////                adapter_oct = new MyAdapter(list_oct);
//                recyclerView_oct.setAdapter(adapter_oct);
//                list_oct.clear();
//                if (consulationDetailResponse.data.MYJY != null)
//                    list_oct.addAll(consulationDetailResponse.data.MYJY);
//                adapter_oct.notifyDataSetChanged();
//
//                GridLayoutManager manager_abc = new GridLayoutManager(AddReferralActivity.this, 5);
//                recyclerView_abc.setLayoutManager(manager_abc);
////                adapter_abc = new MyAdapter(list_abc);
//                recyclerView_abc.setAdapter(adapter_abc);
//                list_abc.clear();
//                if (consulationDetailResponse.data.LCJC != null)
//                    list_abc.addAll(consulationDetailResponse.data.LCJC);
//                adapter_abc.notifyDataSetChanged();
//
//                GridLayoutManager manager_bl = new GridLayoutManager(AddReferralActivity.this, 5);
//                recyclerView_bl.setLayoutManager(manager_bl);
////                adapter_bl = new MyAdapter(list_bl);
//                recyclerView_bl.setAdapter(adapter_bl);
//                list_bl.clear();
//                if (consulationDetailResponse.data.WSWJ != null)
//                    list_bl.addAll(consulationDetailResponse.data.WSWJ);
//                adapter_bl.notifyDataSetChanged();
////
//                GridLayoutManager manager_gyfxy = new GridLayoutManager(AddReferralActivity.this, 5);
//                recyclerView_gyfxy.setLayoutManager(manager_gyfxy);
////                adapter_gyfxy = new MyAdapter(list_gyfxy);
//                recyclerView_gyfxy.setAdapter(adapter_gyfxy);
//                list_gyfxy.clear();
//                if (consulationDetailResponse.data.JZJY != null)
//                    list_gyfxy.addAll(consulationDetailResponse.data.JZJY);
//                adapter_gyfxy.notifyDataSetChanged();
////
////                GridLayoutManager manager_lxd = new GridLayoutManager(PatientDetailActivity.this, 5);
////                recyclerView_lxd.setLayoutManager(manager_lxd);
////                adapter_lxd = new MyAdapter(list_lxd);
////                recyclerView_lxd.setAdapter(adapter_lxd);
////                list_lxd.clear();
////                if (consulationDetailResponse.data.LXD != null)
////                    list_lxd.addAll(consulationDetailResponse.data.LXD);
////                adapter_lxd.notifyDataSetChanged();
////
////                GridLayoutManager manager_syj = new GridLayoutManager(PatientDetailActivity.this, 5);
////                recyclerView_syj.setLayoutManager(manager_syj);
////                adapter_syj = new MyAdapter(list_syj);
////                recyclerView_syj.setAdapter(adapter_syj);
////                list_syj.clear();
////                if (consulationDetailResponse.data.SYJ != null)
////                    list_syj.addAll(consulationDetailResponse.data.SYJ);
////                adapter_syj.notifyDataSetChanged();
//            }
//
//            @Override
//            public void onError(Throwable e) {
//                e.printStackTrace();
//                if (e instanceof BusinessException) {
//                    if (((BusinessException) e).errorCode == 700) {
//                        Toast.makeText(AddReferralActivity.this, "登录失败，请重新登录", Toast.LENGTH_SHORT).show();
//                    }
//                }
//            }
//
//            @Override
//            public void onComplete() {
//
//            }
//        });
//    }
//
//
//    private void editConsultation() {
//        if (hospital_id == 0 || department_id == 0 || doctor_id == 0) {
//            Toast.makeText(this, "请选择医院", Toast.LENGTH_SHORT).show();
//            return;
//        }
//
//        if (!MatchUtil.checkIDCard(edt_id_card.getText().toString().trim(), AddReferralActivity.this)) {
//            Toast.makeText(this, "身份证有误", Toast.LENGTH_SHORT).show();
//            return;
//        }
//
//        ydczURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_eye_photo) {
//
//            ydczURL = ydczURL + photo.resourceId + ",";
//        }
//
//        octURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_oct) {
//
//            octURL = octURL + photo.resourceId + ",";
//        }
//
//        abcURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_abc) {
//
//            abcURL = abcURL + photo.resourceId + ",";
//        }
//
//        blURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_bl) {
//
//            blURL = blURL + photo.resourceId + ",";
//        }
//
//
//        RestProxy.getInstance().editConsultation(time_id + "", hospital_id + "," + hospital_id_1, edt_name.getText().toString().trim(), edt_phone.getText().toString().trim(), edt_id_card.getText().toString().trim(), edt_gender.getText().toString().trim(), edt_address.getText().toString().trim(), startTime, doctor_id + "," + doctor_id_1, edt_reason.getText().toString().trim(), department_id + "," + department_id_1, edt_naked_right_eye.getText().toString().trim(), edt_naked_left_eye.getText().toString().trim(), edt_cured_right_eye.getText().toString().trim(), edt_cured_left_eye.getText().toString().trim(), edt_pressure_right_eye.getText().toString().trim(), edt_pressure_left_eye.getText().toString().trim(), edt_zs.getText().toString().trim(), edt_xbs.getText().toString().trim(), edt_jws.getText().toString().trim(), edt_gms.getText().toString().trim(),
//                ydczURL, octURL, abcURL, blURL,gyfxyURL, getBirth(), 1 + "", patient.patientId, patient.diagnoseId, patient.medhisId, new Observer<BaseResponse>() {
//                    @Override
//                    public void onSubscribe(Disposable d) {
//
//                    }
//
//                    @Override
//                    public void onNext(BaseResponse baseResponse) {
//                        finish();
//                    }
//
//                    @Override
//                    public void onError(Throwable e) {
//                        if (e instanceof BusinessException) {
//                            Toast.makeText(AddReferralActivity.this, ((BusinessException) e).errorDescription, Toast.LENGTH_SHORT).show();
//                        }
//                    }
//
//                    @Override
//                    public void onComplete() {
//
//                    }
//                });
//    }
//
//    private void saveConsultation() {
////        if (hospital_id == 0 || department_id == 0 || doctor_id == 0) {
////            Toast.makeText(this, "请选择医院", Toast.LENGTH_SHORT).show();
////            return;
////        }
//
//        if (!MatchUtil.checkIDCard(edt_id_card.getText().toString().trim(), AddReferralActivity.this)) {
//            Toast.makeText(this, "身份证有误", Toast.LENGTH_SHORT).show();
//            return;
//        }
//
//        ydczURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_eye_photo) {
//
//            ydczURL = ydczURL + photo.resourceId + ",";
//        }
//
//        octURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_oct) {
//
//            octURL = octURL + photo.resourceId + ",";
//        }
//
//        abcURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_abc) {
//
//            abcURL = abcURL + photo.resourceId + ",";
//        }
//
//        blURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_bl) {
//
//            blURL = blURL + photo.resourceId + ",";
//        }
//
//        RestProxy.getInstance().saveConsultation(time_id + "", hospital_id + "," + hospital_id_1, edt_name.getText().toString().trim(), edt_phone.getText().toString().trim(), edt_id_card.getText().toString().trim(), edt_gender.getText().toString().trim(), edt_address.getText().toString().trim(), startTime, doctor_id + "," + doctor_id_1, edt_reason.getText().toString().trim(), department_id + "," + department_id_1, edt_naked_right_eye.getText().toString().trim(), edt_naked_left_eye.getText().toString().trim(), edt_cured_right_eye.getText().toString().trim(), edt_cured_left_eye.getText().toString().trim(), edt_pressure_right_eye.getText().toString().trim(), edt_pressure_left_eye.getText().toString().trim(), edt_zs.getText().toString().trim(), edt_xbs.getText().toString().trim(), edt_jws.getText().toString().trim(), edt_gms.getText().toString().trim(),
//                ydczURL, octURL, abcURL, blURL,gyfxyURL, getBirth(), type + "", new Observer<BaseResponse>() {
//                    @Override
//                    public void onSubscribe(Disposable d) {
//
//                    }
//
//                    @Override
//                    public void onNext(BaseResponse baseResponse) {
//                        finish();
//                    }
//
//                    @Override
//                    public void onError(Throwable e) {
//                        e.printStackTrace();
//                        if (e instanceof BusinessException) {
//                            Toast.makeText(AddReferralActivity.this, ((BusinessException) e).errorDescription, Toast.LENGTH_SHORT).show();
//                        }
//                    }
//
//                    @Override
//                    public void onComplete() {
//
//                    }
//                });
//    }
//
//    private void startConsultation(String patientId, String diagnoseId, String medicalRecId) {
//        if (hospital_id == 0 || department_id == 0 || doctor_id == 0) {
//            Toast.makeText(this, "请选择医院", Toast.LENGTH_SHORT).show();
//            return;
//        }
//
//        if (!MatchUtil.checkIDCard(edt_id_card.getText().toString().trim(), AddReferralActivity.this)) {
//            Toast.makeText(this, "身份证有误", Toast.LENGTH_SHORT).show();
//            return;
//        }
//
//        ydczURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_eye_photo) {
//
//            ydczURL = ydczURL + photo.resourceId + ",";
//        }
//
//        octURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_oct) {
//
//            octURL = octURL + photo.resourceId + ",";
//        }
//
//        abcURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_abc) {
//
//            abcURL = abcURL + photo.resourceId + ",";
//        }
//
//        blURL = "";
//        for (ConsulationDetailResponse.Photo photo : list_bl) {
//
//            blURL = blURL + photo.resourceId + ",";
//        }
//
//        RestProxy.getInstance().startConsultation(time_id + "", hospital_id + "," + hospital_id_1, edt_name.getText().toString().trim(), edt_phone.getText().toString().trim(), edt_id_card.getText().toString().trim(), edt_gender.getText().toString().trim(), edt_address.getText().toString().trim(), startTime, doctor_id + "," + doctor_id_1, edt_reason.getText().toString().trim(), department_id + "," + department_id_1, edt_naked_right_eye.getText().toString().trim(), edt_naked_left_eye.getText().toString().trim(), edt_cured_right_eye.getText().toString().trim(), edt_cured_left_eye.getText().toString().trim(), edt_pressure_right_eye.getText().toString().trim(), edt_pressure_left_eye.getText().toString().trim(), edt_zs.getText().toString().trim(), edt_xbs.getText().toString().trim(), edt_jws.getText().toString().trim(), edt_gms.getText().toString().trim(),
//                ydczURL, octURL, abcURL, blURL, gyfxyURL,getBirth(), 1 + "", patientId, diagnoseId, medicalRecId, new Observer<BaseResponse>() {
//                    @Override
//                    public void onSubscribe(Disposable d) {
//
//                    }
//
//                    @Override
//                    public void onNext(BaseResponse baseResponse) {
//                        finish();
//                    }
//
//                    @Override
//                    public void onError(Throwable e) {
//                        if (e instanceof BusinessException) {
//                            Toast.makeText(AddReferralActivity.this, ((BusinessException) e).errorDescription, Toast.LENGTH_SHORT).show();
//                        }
//                    }
//
//                    @Override
//                    public void onComplete() {
//
//                    }
//                });
//    }
//    @OnClick(R.id.edt_gender)
//    void edt_gender(){
//        showPopListView(edt_gender);
//    }
//
//    private void showPopListView(View view) {
//        View contentView = LayoutInflater.from(this).inflate(R.layout.sex_list, null);
//        contentView.findViewById(R.id.man).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                edt_gender.setText("男");
//                mListPopWindow.dissmiss();
//            }
//        });
//        contentView.findViewById(R.id.woman).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                edt_gender.setText("女");
//                mListPopWindow.dissmiss();
//            }
//        });
//        //创建并显示popWindow
//        mListPopWindow = new CustomPopWindow.PopupWindowBuilder(this)
//                .setView(contentView)
//                .size(view.getMeasuredWidth(), 0) // 显示大小
//                .create()
//                .showAsDropDown(view, Gravity.NO_GRAVITY, 0, 0);
//    }
//
//}
